package com.boil.qz.safekavass.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by ChenYong on 2017-05-19.
 * <br>
 * 微信用户实体类。
 */
@Entity
@Table(name = "TB_WEIXIN_USER")
public class WeixinUser implements Serializable {
    /**
     * 序列化 ID
     */
    private static final long serialVersionUID = 8514721046807237380L;
    /**
     * 编号，主键
     */
    @Id
    @SequenceGenerator(name = "SgWeixinUser", sequenceName = "SE_WEIXIN_USER", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SgWeixinUser")
    private Long id;
    /**
     * 用户所在的分组 ID
     */
    private Long groupid;
    /**
     * 用户的标识，唯一
     */
    private String openid;
    /**
     * 只有在用户将公众号绑定到微信开放平台帐号后，才会出现该字段
     */
    private String unionid;
    /**
     * 用户是否关注该公众号标识，值为0时，代表此用户没有关注该公众号，拉取不到其余信息
     */
    private Integer subscribe;
    /**
     * 用户的昵称
     */
    private String nickname;
    /**
     * 用户的性别，值为1时是男性，值为2时是女性，值为0时是未知
     */
    private Integer sex;
    /**
     * 语言
     */
    private String language;
    /**
     * 用户所在城市
     */
    private String city;
    /**
     * 用户所在省份
     */
    private String province;
    /**
     * 用户所在国家
     */
    private String country;
    /**
     * 用户头像，最后一个数值代表正方形头像大小（有0、46、64、96、132数值可选，0代表640*640正方形头像），用户没有头像时该项为空。若用户更换头像，原有头像URL将失效
     */
    private String headimgurl;
    /**
     * 公众号运营者对粉丝的备注，公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
     */
    private String remark;
    /**
     * 手机号，唯一
     */
    private String phone;
    /**
     * 关注时间（微信传过来的时间）
     */
    private Date subscribeTime;
    /**
     * 取消关注时间（本地系统的时间）
     */
    private Date unsubscribeTime;

    /**
     * 默认构造器。
     */
    public WeixinUser() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getGroupid() {
        return groupid;
    }

    public void setGroupid(Long groupid) {
        this.groupid = groupid;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getUnionid() {
        return unionid;
    }

    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    public Integer getSubscribe() {
        return subscribe;
    }

    public void setSubscribe(Integer subscribe) {
        this.subscribe = subscribe;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getHeadimgurl() {
        return headimgurl;
    }

    public void setHeadimgurl(String headimgurl) {
        this.headimgurl = headimgurl;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getSubscribeTime() {
        return subscribeTime;
    }

    public void setSubscribeTime(Date subscribeTime) {
        this.subscribeTime = subscribeTime;
    }

    public Date getUnsubscribeTime() {
        return unsubscribeTime;
    }

    public void setUnsubscribeTime(Date unsubscribeTime) {
        this.unsubscribeTime = unsubscribeTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        WeixinUser that = (WeixinUser) o;

        return id != null ? id.equals(that.id) : that.id == null;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("WeixinUser{");
        sb.append("id=").append(id);
        sb.append(", groupid=").append(groupid);
        sb.append(", openid='").append(openid).append('\'');
        sb.append(", unionid='").append(unionid).append('\'');
        sb.append(", subscribe=").append(subscribe);
        sb.append(", nickname='").append(nickname).append('\'');
        sb.append(", sex=").append(sex);
        sb.append(", language='").append(language).append('\'');
        sb.append(", city='").append(city).append('\'');
        sb.append(", province='").append(province).append('\'');
        sb.append(", country='").append(country).append('\'');
        sb.append(", headimgurl='").append(headimgurl).append('\'');
        sb.append(", remark='").append(remark).append('\'');
        sb.append(", phone='").append(phone).append('\'');
        sb.append(", subscribeTime=").append(subscribeTime);
        sb.append(", unsubscribeTime=").append(unsubscribeTime);
        sb.append('}');
        return sb.toString();
    }
}